﻿using CodeMan.Domain.Shared;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeManDesktopBlazor.Exts
{
    public enum IceEnum
    {
        [Display(Name = "false or true")]
        [Description("bool")]
        bbool = 0,
        [Display(Name = "-128-127 or 0-255 a")]
        [Description("byte")]
        bbyte = 1,
        [Display(Name = "-2 15 to 2 15 -1")]
        [Description("short")]
        sshort = 2,
        [Display(Name = "-2 31 to 2 31 -1")]
        [Description("int")]
        iint = 3,
        [Display(Name = "-2 63 to 2 63 -1")]
        [Description("long")]
        llong = 4,
        [Display(Name = "IEEE single-precision")]
        [Description("float")]
        ffloat = 5,
        [Display(Name = "IEEE double-precision")]
        [Description("double")]
        ddouble = 6,
        [Display(Name = "All Unicode characters")]
        [Description("string")]
        sstring = 7
    }
    public static class EnumExts
    {
        /// <summary>
        /// 获取basic-types ice 应射
        /// https://doc.zeroc.com/ice/3.7/the-slice-language/basic-types
        /// </summary>
        /// <param name="typeEnum"></param>
        /// <returns></returns>
        public static IceEnum GetDescForIce(this AttrTypeEnum typeEnum)
        {
            var result = IceEnum.sstring;
            switch (typeEnum)
            {
                case AttrTypeEnum.iint:
                    result = IceEnum.iint;
                    break;
                case AttrTypeEnum.sshort:
                case AttrTypeEnum.iint16:
                    result = IceEnum.sshort;
                    break;
                case AttrTypeEnum.ffloat:
                    result = IceEnum.ffloat;
                    break;
                case AttrTypeEnum.lLong:
                    result = IceEnum.llong;
                    break;
                case AttrTypeEnum.ddecimal:
                case AttrTypeEnum.ddouble:
                    result = IceEnum.ddouble;
                    break;
                case AttrTypeEnum.bbool:
                    result = IceEnum.bbool;
                    break;
                case AttrTypeEnum.cchar:
                case AttrTypeEnum.sssbyte:
                case AttrTypeEnum.ssbyte:
                    result = IceEnum.bbyte;
                    break;
                default:
                    break;
            }
            return result;
        }
    }


}
